package com.winit.menu.repository;

import com.winit.common.base.repository.BaseRepository;
import com.winit.menu.model.MatrixMenu;
import org.springframework.data.cassandra.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by wangjian on 2017/11/22.
 */
@Repository
public interface MatrixMenuRepository extends BaseRepository<MatrixMenu, String> {

    MatrixMenu findById(String id);
//    @Query("select * from matrix_menu where menu_id = ?0 and parent_id = ?1 allow filtering")
//    List<MatrixMenu> findAllByMenu_idAndParent_id(String menu_id,String parent_id);

    @Query(value = "select * from matrix_menu where parent_id = '0' and is_del = '1' and sys = ?0 allow filtering")
    MatrixMenu findRootBySys(String sys);
    @Query(value = "select * from matrix_menu where parent_id = ?0 and id = ?1 and sys = ?2 and is_del = ?3 allow filtering")
    MatrixMenu findByParentIdAndIdAndSysAndIsDel(String parentId, String menuId, String sys, String isDel);

    @Query(value = "select * from matrix_menu where menu_num = ?0 allow filtering")
    MatrixMenu findByMenuNum(String menuNum);
    @Query(value = "select * from matrix_menu where menu_name = ?0 allow filtering")
   List<MatrixMenu>  findByMenuName(String menuName);

    @Query(value = "select * from matrix_menu where sys = ?0 allow filtering")
    List<MatrixMenu> findBySys(String sys);
    @Query(value = "select * from matrix_menu where parent_id = ?0 and is_del = '1' allow filtering")
    List<MatrixMenu> findByParentId(String parentId);
}
